package com.superman.supermarket.client.activity;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.superman.mvpframe.client.ajax.PostManAsyncCallBack;
import com.superman.mvpframe.client.mvp.IPageView;
import com.superman.mvpframe.client.mvp.IPageViewPresenter;
import com.superman.mvpframe.client.utils.StringUtils;
import com.superman.mvpframe.client.utils.XJsonUtil;
import com.superman.mvpframe.client.widget.mescroll.UpAndDownCallBack;
import com.superman.supermarket.client.mvp.ShopAbstractActivity;
import com.superman.supermarket.client.view.skulist.SkuListView;

/**
 * 分类商品列表
 * 
 * @author superman
 * @version 2018年8月2日下午5:08:48
 */
public class CategorySkuListActivity extends ShopAbstractActivity implements UpAndDownCallBack {

	private String cid;
	@Inject
	SkuListView skuListView;

	@Override
	public void getListDataByPage(int page) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("CATALOG_ID", cid);
		map.put("PAGE_INDEX", page);
		postman.post("bujie/catalog/skus", map, new PostManAsyncCallBack() {

			@Override
			public void onBusinessError(String statusCode) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onBusinessOK(String response) {
				skuListView.getPullToRefreshView().endBySize(XJsonUtil.getList(response), XJsonUtil.getCount(response));
			}
		});
	}

	@Override
	public IPageView getView() {
		return skuListView;
	}

	@Override
	public IPageViewPresenter getViewPresenter() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onActivity(EventBus eventBus) {
	}

	@Override
	public void popToRefresh() {
		// TODO Auto-generated method stub
	}

	@Override
	public void popToRefresh(Object contextData) {
		// TODO Auto-generated method stub

	}

	@Override
	public void pushToRefresh() {
		cid = Window.Location.getParameter("cid");
		String cname = Window.Location.getParameter("cname");

		skuListView.getPullToRefreshView().initMeScroll(this, "1.2rem", "0rem");
		skuListView.setPageHeaderText(StringUtils.isEmpty(cname) ? "商品列表" : cname);
	}

}
